using UnityEngine;

public class BarController : MonoBehaviour
{
    private bool _isOnMove;
    private Vector3 _pointerOffset;
    private bool _finishedDrag;
    //private Transform _headTransform;
        
    [SerializeField] private Camera _camera;

    private void Awake()
    {
        if(_camera == null)
            _camera = Camera.main;
    }

    private void OnMouseDown()
    {
        _pointerOffset = transform.position - _camera.ScreenToWorldPoint(Input.mousePosition);
        _finishedDrag = false;
    }

    private void OnMouseDrag()
    {
        Vector3 newPosition = _camera.ScreenToWorldPoint(Input.mousePosition) + _pointerOffset;
        transform.position = new Vector3(newPosition.x, newPosition.y, transform.position.z);
    }

    private void OnMouseUp()
    {
        _finishedDrag = true;
    }

    public void SetFinishedDrag(bool value)
    {
        _finishedDrag = value;
    }

    public bool GetFinishedDrag()
    {
        return _finishedDrag;
    }
}
